import table from '@/components/dt/table/render.js'
import Opt from '@/components/dt/info/Opt.js'
let _this = null
class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      {
        field: 'orgName',
        minWidth: 200,
        treeNode: true,
        slots: {
          header: (params, h) => {
            return table.header.headerSel(_this, h, {
              val: _this.currentOrgId,
              placeholder: '',
              key: '11',
              width: '150px',
              options: _this.orgLevel1,
              change: (info) => {
                _this.orgChange(info)
              }
            })
          }
        }
      },

      {
        field: 'isTaskAssess',
        visible: _this.currentRow.type == 3 ? false : true,
        minWidth: 150,
        cell: (info) => {
          return {
            edit: {
              key: 'isTaskAssess',
              placeholder: '请选择',
              switch: {},
              change: (val) => {
                _this.isTaskAssessChange(val, info)
              }
            }
          }
        },
        slots: {
          header: (params, h) => {
            return table.cell.spanA(_this, h, {
              event: 'batch',
              title: '是否生成',
              tit: '批处理',
              data: params
            })
          }
        }
      },
      {
        field: 'isAssess',
        minWidth: 150,
        cell: (info) => {
          return {
            edit: {
              disabled: _this.currentRow.type != 3 && !info.isTaskAssess,
              key: 'isAssess',
              placeholder: '请选择',
              switch: {},
              change: (val) => {
                _this.isAssessChange(val, info)
              }
            }
          }
        },
        slots: {
          header: (params, h) => {
            return table.cell.spanA(_this, h, {
              event: 'batch',
              title: '是否扣分',
              tit: '批处理',
              data: params.row
            })
          }
        }
      },
      {
        title: '操作',
        fixed: 'right',
        width: 180,
        align: 'center',
        slots: {
          default: (params, h) => {
            let btns = []
            btns.push({
              title: '特殊规则',
              event: 'specialRules',
              data: params.row
            })
            return table.cell.btns(_this, h, btns)
          }
        }
      }
    ]
  }
}

export default Column
